import bus from '@/bus'
const data = {
  status: 'pass',
  storeName: '',
  date: '',
  total: 1,
  pageSize: window.$pageSize,
  current: 1,
  data: [],
  columns: [{
    title: '优惠券名称', 
    key: 'couponName', 
    minWidth: 200,
    align: 'left'
  }, {
    title: '优惠金额',
    key: 'discountValue',
    minWidth: 200,
    align: 'left',
    render: (h, params) => {
      let row = params.row
      let denominationCondition
      // let denominationCondition = row.couponDiscountType == 'DISCOUNT_COUPON' ? row.discountRuleDescription + '折' : row.denomination + '元/满' + row.useCondition + '元'
      switch (row.couponDiscountType) {
        case 'DISCOUNT_COUPON':
          const length = row.discountGroupList.length 
          if (length === 1) {
            denominationCondition = `${row.discountGroupList[0].discount}折`
          } else {
            denominationCondition = `${row.discountGroupList[0].discount} - ${row.discountGroupList[length - 1].discount}折`
          }
          break
        case 'DENOMINATION_COUPON':
          denominationCondition = `${row.denomination}元/满${row.useCondition}元`
          break
        case 'CASH_COUPON':
          denominationCondition = `${row.denomination}元`
          break
      }
      return h('div', denominationCondition)
    }
  }, {
    title: '状态',
    key: 'statusStr',
    align: 'left',
    minWidth: 200
  }, {
    title: '时间',
    minWidth: 200,
    key: 'receiveDate',
    align: 'left'
  }, {
    title: '生效时间',
    key: 'activatedDate',
    minWidth: 200,
    align: 'left'
  }, {
    title: '使用时间',
    key: 'useDate',
    minWidth: 200,
    align: 'left'
  }, {
    title: '使用订单号',
    minWidth: 230,
    key: 'useOrderSn',
    align: 'left'
  }, {
    title: '订单总金额',
    minWidth: 200,
    key: 'useOrderAmount',
    align: 'right'
  }, {
    title: '抵扣金额',
    minWidth: 200,
    key: 'discountAmount',
    align: 'right'
  }, {
    title: '送券订单号',
    minWidth: 230,
    key: 'sendOrderSn',
    align: 'left'
  }, {
    title: '送券的商品', 
    minWidth: 250,
    key: 'productName', 
    align: 'left',
    tooltip: true,
    render: (h, p) => {
      // 如果是通过订单赠送的优惠券，商品展示用文案“订单送券”样式展示，条码也是“订单送券”
      //couponActivateType === 'ACTIVITY_FULL_GIFT_COUPON' 则代表是 通过订单赠送的优惠券
      let text = p.row.couponActivateType === 'ACTIVITY_FULL_GIFT_COUPON' ? '订单送券' : p.row.productName
      return <div>{text}</div>
    }
  }, {
    title: '入库条码',
    key: 'barCode',
    minWidth: 200,
    align: 'left',
    tooltip: true,
    render: (h, p) => {
      // 如果是通过订单赠送的优惠券，商品展示用文案“订单送券”样式展示，条码也是“订单送券”
      //couponActivateType === 'ACTIVITY_FULL_GIFT_COUPON'  则代表是 通过订单赠送的优惠券
      let text = p.row.couponActivateType === 'ACTIVITY_FULL_GIFT_COUPON' ? '订单送券' : p.row.barCode
      return <div>{text}</div>
    }
  }, {
    title: '失效时间',
    key: 'invalidDate',
    minWidth: 200,
    align: 'left'
  }, {
    title: '失效原因',
    key: 'invalidReason',
    minWidth: 200,
    align: 'left'
  }, {
    title: '操作',
    key: 'operate',
    minWidth: 80,
    align: 'right',
    render: (h, params) => {
      const detailBtn = h('Button', {
        props: {
          size: 'small',
          type: 'primary'
        },
        on: {
          click: () => {
            bus.$emit('onClickListDetail', { couponCode: params.row.couponCode, couponId: params.row.id })
          }
        }
      }, '详情')
      return h('div', [detailBtn])
    }
  }]
}

export default data